object class0425 {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession
      .builer()
      .master("local[*]")
      .appName("sparkBase")
      .getOrCreate()
    val sc = spark.sparkContext

    val pproperties: Properties = new Properties();
    properties.setProperty("user", "root")
    properties.setProperty("password", "123456")
    properties.setProperty("driver", "com.mysql.jdbc:mysql://localhost:3306/test?" + "verifyServerCertificate=false&useSSL=false", "Table1", properties)

    mysqlScore.createTempView("Table1")
    val data:RDD[String] = sc.makeRDD(Array("张三，1001，100","李四,1002,99"))
    val dataRDD = data.map(_.split(","))
    val scoreRDD = dataRDD.map(x => Score(x(0),x(1),x(2)))
    import spart.implicits._
    val dataDF = scoreRDD.toDF()
    dataDF.write.mode("append").jdbc("jdbc:mysql://localhost:3306/test?" + "verifyServerCertificate=false&useSSL=false", "Table1", propertie)
    mysqlScore.show()
    sc.stop()
  }
  case class Score(name:String,number:String,score:String)
}
